package com.tests;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONObject;
import com.hystrix.OrderHystrixCommand;
import com.service.IndexService;

@Controller
public class IndexController {
	@Autowired
	private IndexService  indexService;
	@RequestMapping("/index")
	@ResponseBody
	public JSONObject index() {
		JSONObject json=indexService.index();
		System.out.println("当前线程名称:" + Thread.currentThread().getName() + ",订单服务调用会员服务:member:" + json);
		return json;
	}
	
	@RequestMapping("/indexHystrix")
	@ResponseBody
	public JSONObject indexHystrix() {
		OrderHystrixCommand hystrix =new OrderHystrixCommand(indexService);
		JSONObject json=hystrix.execute();
		return json;
	}
	
	@RequestMapping("/findOrderIndex")
	@ResponseBody
	public Object findIndex() {
		System.out.println("当前线程:" + Thread.currentThread().getName() + ",findOrderIndex");
		return "findOrderIndex";
	}

}

